home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 October / MACPOWER-1997-10.ISO.7z / MACPOWER-1997-10.ISO / AMUG / PROGRAMMING / Mac F2C 1.3.5.sit / Mac F2C 1.3.5 / Mac F2C Libraries / libI77 Sources / access.c next >
Text File  |  1995-01-28  |  707b  |  47 lines

  1. /*
  2.     This function returns 0 if file called fileName exists,
  3.     1 otherwise.
  4.     
  5.     IMT 28 Nov 94
  6. */
  7.  
  8. #include <Files.h>
  9.  
  10. static StringPtr CopyCtoPstr( StringPtr pStr, char *cStr );
  11.  
  12.  
  13.  
  14. int access( char *fileName, int notUsed )
  15. {    
  16.     OSErr     err;
  17.     short     vRefNum;
  18.     FInfo     info;
  19.     Str255    pFileName;
  20.     
  21.     CopyCtoPstr( pFileName, fileName );            /* Make name a Pascal string */
  22.         
  23.     err = GetFInfo( pFileName, 0, &info );        /* Check on the default volume */
  24.     
  25.     if ( err )
  26.         return  1;
  27.     else
  28.         return  0;
  29. }
  30.  
  31.  
  32. static StringPtr CopyCtoPstr( StringPtr pStr, char *cStr )
  33. {
  34.     short        i;
  35.     char        *p;
  36.     
  37.     i = 0;
  38.     p = ((char *) pStr) + 1;
  39.     while ( *cStr && i < 255 )
  40.     {
  41.         *p++ = *cStr++;
  42.         i++;
  43.     }
  44.     *pStr = i;
  45.     
  46.     return  (StringPtr) pStr;
  47. }